package com.changgou.search.controller;

import com.changgou.common.pojo.Result;
import com.changgou.common.pojo.StatusCode;
import com.changgou.search.service.SkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 索引库的导入
 */
@RestController
@CrossOrigin
@RequestMapping("/search")
public class SkuController {
    @Autowired
    private SkuService skuService;

    /**
     * 导入索引库
     * @return
     */
    @GetMapping(value = "/import")
    public Result importData(){
        skuService.importData();
        return new Result(true, StatusCode.OK, "导入索引库成功");

    }
    @GetMapping
    public Map search(@RequestParam(required = false) Map<String,String> searchMap){
        return skuService.search(searchMap);


    }

}
